using EPiServer;
using EPiSugar.Content;
using EPiSugar.Markup;

namespace EPiSugar.Web.UI
{
    /// <summary>
    /// Convenience base class for accessing EPiSugar functionality.
    /// </summary>
    /// <typeparam name="T">The type of entity this page handles.</typeparam>
    public abstract class EntityPage<T> : TemplatePage where T: class 
    {
        protected  virtual ContentGenerator Content
        {
            get { return new ContentGenerator(this, this); }
        }
        protected virtual TagGenerator Tags
        {
            get { return new TagGenerator(this); }
        }

        private EntityAdapter.EntityContext<T> entity;
        protected virtual EntityAdapter.EntityContext<T> Entity
        {
            get { return entity ?? (entity = new EntityAdapter.EntityContext<T>(Current.Model, this)); }
            set { entity = value; }
        }
    }
}